<template>
    <div>
    
       <div class="home-header">
    <van-tabs @click="onClick" >
      <van-tab v-for="item in cates" :key="item.id" :title="item.catename" :name="item.id" >
  <!-- {{ item.catename}} -->
  </van-tab>
</van-tabs>
     <!-- <router-link v-for="item in cates" :key="item.id" :to="'/list?id='+item.id">{{item.catename}}</router-link> -->
   
       </div>
    </div>
</template>
<script>
import {getHomeCate} from "../../../http/http"
import { Tab, Tabs } from 'vant';
export default {
    data() {
        return {
            cates:[]
        }
    },
    methods: {
           onClick(name, title) {
               console.log(name);
               console.log(title);
            //    $router路由跳转
            // $route  路由信息
               this.$router.push('/list?id='+name+'&type=1')
            //  console.log(this.cates.forEach((item,index) => {
            //      console.log(item[inde]);
            //  }));
    //     name=this.item.id
    },
    },
    mounted() {
       getHomeCate().then(res=>{
            console.log(res);
           this.cates=res.data.list
        })
    },
}
</script>
<style scoped>
.home-header{
    background: pink;
    overflow: hidden;
}
.home-header a{
    float: left;
    margin: 0.2rem;
    line-height: 0.6rem;
}
</style>